﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master_form.master" AutoEventWireup="true" CodeFile="phan_lop.aspx.cs" Inherits="App_Form_tuyen_sinh_phan_lop" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript" src="../js/plugin/CellEditing.js"></script>

    <script type="text/javascript">
        Ext.Loader.setConfig({
            enabled: true
        });
        Ext.Loader.setPath('Ext.ux', '../ux');

        Ext.require(['*']);

        Ext.require([
    'Ext.selection.CellModel',
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.state.*',
    'Ext.form.*',
    'Ext.grid.Panel',
        'Ext.layout.container.Column'
        ]);


        Ext.onReady(function () {

            Ext.QuickTips.init();

            var bd = Ext.getBody();

            var gridForm = Ext.create('Ext.form.Panel', {
                id: 'company-form',
                frame: true,
                bodyPadding: 5,
                width: 1024,
                layout: {
                    type: 'table',
                    columns: 1
                },
                fieldDefaults: {
                    labelAlign: 'left',
                    msgTarget: 'side'
                },

                items: [
                    {
                        columnWidth: '100%',
                        margin: '0 0 0 10',
                        xtype: 'fieldset',
                        title: 'Thông tin môn học',
                        width: 1024,
                        columnWidth: 1,
                        layout: 'anchor',
                        defaults: {
                            labelWidth: 100
                        },
                        defaultType: 'textfield',
                        items: [
                             {
                                 xtype: 'fieldcontainer',
                                 combineErrors: false,
                                 layout: {
                                     type: 'hbox',
                                     defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                 },
                                 items: [
                                 { xtype: 'displayfield', width: 70, value: 'Năm TS :' },
                                 {
                                     width: 150, xtype: 'combo', value: 'I', emptyText: 'Chọn năm học',
                                     triggerAction: 'all', forceSelection: true, editable: false,
                                     id: 'nam_hoc', name: 'nam_hoc', displayField: 'ten', valueField: 'id',
                                     queryMode: 'local'
                                 },
                                  { xtype: 'displayfield', width: 70, value: 'Khối thi :' },
                                  {
                                      width: 150, xtype: 'combo', triggerAction: 'all', emptyText: 'Chọn khối thi',
                                      forceSelection: true, editable: false, id: 'khoithi',
                                      name: 'khoithi', displayField: 'Ten', valueField: 'Ma_khoi'
                                  },
                                  { xtype: 'displayfield', width: 70, value: 'Bộ môn :' },
                                  {
                                      xtype: 'combo', triggerAction: 'all',
                                      emptyText: 'Chọn bộ môn', forceSelection: true, editable: false,
                                      id: 'bo_mon', name: 'bo_mon', displayField: 'TenNganh', valueField: 'Id_Nganh', store: null,
                                      listeners: {
                                          select: function (combo, record, index) {
                                              if (record.length > 0) {
                                                  var id_nganh = record[0].get('Id_Nganh');
                                                  //Goi service
                                                  wdkhp.Fs_NganhDT(id_nganh, P_MON_NGANH_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                              }
                                          }
                                      }
                                  },
                                  { xtype: 'displayfield', width: 70, value: 'Ngành ĐT :' },
                                 {
                                     xtype: 'combo', triggerAction: 'all', emptyText: 'Chọn bộ ngành',
                                     forceSelection: true, editable: false, id: 'nganhdt', name: 'nganhdt',
                                     displayField: 'ten', valueField: 'id_nganhdt'
                                 }]
                             },
                             {
                                 xtype: 'fieldcontainer',
                                 combineErrors: false,
                                 layout: {
                                     type: 'hbox',
                                     defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                 },
                                 items: [
                                 { xtype: 'displayfield', width: 70, value: 'Lớp :' },
                                  {
                                      width: 150, xtype: 'combo', value: '',
                                      emptyText: 'Chọn lớp', triggerAction: 'all', forceSelection: true, editable: false,
                                      id: 'lop', name: 'lop', displayField: 'ten_lop', valueField: 'id_lop', queryMode: 'local',
                                      store: null
                                  },
                                   {
                                       name: 'tim',
                                       xtype: 'button',
                                       width: 80,
                                       icon: '../../shared/icons/fam/find.png',
                                       text: 'Tìm', margin: '0 5 0 5',
                                       handler: function () {
                                           var id_nam = Ext.getCmp("nam_hoc").getValue(), b_khoi = Ext.getCmp("khoithi").getValue(),
                                                b_nganhdt = Ext.getCmp("nganhdt").getValue();
                                           wsinh_vien.Fs_XEP_LOP_TIM(id_nam, b_khoi, b_nganhdt, KB_TIM_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                       }
                                   },
                                    {
                                        name: 'add',
                                        xtype: 'button',
                                        margin: '0 5 0 5',
                                        width: 80,
                                        icon: '../../shared/icons/fam/add.gif',
                                        text: 'Xác nhận',
                                        handler: function () {
                                            var a_gtriGrid = new Array();
                                            var i = 0;
                                            var a = Ext.getCmp("tinhdiem").getSelectionModel().getSelection();
                                            for (var i = 0; i < a.length; i++) {
                                                a_gtriGrid[i] = a[i].data.id_ts;
                                            }
                                            //
                                            var b_lop = Ext.getCmp("lop").getValue();
                                            var b_nam_hoc = Ext.getCmp("nam_hoc").getValue();
                                            wsinh_vien.Fs_XEP_LOP_NH(a_gtriGrid, b_lop, b_nam_hoc, nhaodiemP_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                        }
                                    }
                                 ]
                             }
                        ]
                    },
                    {
                        columnWidth: '100%',
                        xtype: 'gridpanel',
                        margin: '5 0 0 10',
                        id: 'tinhdiem',
                        store: null,
                        height: 450,
                        columnLines: true,
                        Scroll: true,
                        selModel: Ext.create('Ext.selection.CheckboxModel'),
                        layout: {
                            defaultMargins: { top: 0, right: 5, bottom: 0, left: 5 }
                        },
                        title: 'Danh sách học sinh',
                        columns: [
                            { id: 'id_ts', flex: 1, hidden: true, hideable: false, dataIndex: 'id_ts' },
                            { id: 'ten', text: 'Họ và tên', width: 200, sortable: true, dataIndex: 'ten' },
                            { id: 'ngay_sinh', text: 'Ngày sinh', width: 150, sortable: true, dataIndex: 'ngay_sinh' },
                            { id: 'gioi_tinh', text: 'Giới tính', width: 150, sortable: true, dataIndex: 'gioi_tinh' },
                            { id: 'Noi_sinh', text: 'Nơi sinh', width: 200, flex: 1, sortable: true, dataIndex: 'Noi_sinh' }
                        ]
                    }],
                renderTo: bd
            });
            wsinh_vien.Fs_XEP_LOP_TTCHUNG(P_LOAD_TTCHUNG, P_LOI_CSDL, P_LOI_TGIAN);
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">

        function P_LOAD_TTCHUNG(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            var a_kq = b_kq.split('@');
            var b_chuoi1 = CH_JSON(a_kq[0]),
                b_chuoi2 = CH_JSON(a_kq[1]),
                b_chuoi3 = CH_JSON(a_kq[2]),
                b_chuoi4 = CH_JSON(a_kq[3]);

            var a_data1 = Ext.create('Ext.data.Store', {
                fields: ['id', 'ten'],
                data: b_chuoi1
            });

            var a_data2 = Ext.create('Ext.data.Store', {
                fields: ['Ma_khoi', 'Ten'],
                data: b_chuoi2
            });

            var cd = Ext.getCmp('nam_hoc');
            cd.bindStore(a_data1);

            var b_hk = Ext.getCmp("khoithi");
            b_hk.bindStore(a_data2);


            var a_data3 = Ext.create('Ext.data.Store', {
                fields: ['Id_Nganh', 'TenNganh'],
                data: b_chuoi3
            });

            var c = Ext.getCmp('bo_mon');
            c.bindStore(a_data3);


            var a_data4 = Ext.create('Ext.data.Store', {
                fields: ['id_lop', 'ten_lop'],
                data: b_chuoi4
            });

            var c = Ext.getCmp('lop');
            c.bindStore(a_data4);
        }
        function P_MON_NGANH_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            else {
                var b_chuoi = CH_JSON(b_kq);

                var a_data = Ext.create('Ext.data.Store', {
                    fields: ['id_nganhdt', 'ten'],
                    data: b_chuoi
                });

                var b = Ext.getCmp('nganhdt');
                b.clearValue();
                b.setValue("");
                b.setValue(null);
                b.bindStore(a_data);
            }
        }
        function diem_ts_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            var a_kq = b_kq.split("@");

            var b_chuoi1 = CH_JSON(a_kq[0]);
            var a_data1 = Ext.create('Ext.data.Store', {
                fields: ['id', 'ten'],
                data: b_chuoi1
            });
            var d = Ext.getCmp('phong_thi');
            d.bindStore(a_data1);

            var b_chuoi2 = CH_JSON(a_kq[1]);
            var a_data2 = Ext.create('Ext.data.Store', {
                fields: ['ID', 'Ten'],
                data: b_chuoi2
            });

            var b_hk = Ext.getCmp("monthi");
            b_hk.bindStore(a_data2);
        }
        function KB_TIM_P_KQ(b_kq) {
            var b = Ext.getCmp('tinhdiem');
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                b.bindStore(null);
                return;
            }
            else {

                var b_chuoi1 = CH_JSON(b_kq);
                var store = Ext.create('Ext.data.JsonStore', {
                    fields: ["id_ts", "ten", "ngay_sinh", "gioi_tinh", "Noi_sinh"],
                    data: b_chuoi1
                });

                b.bindStore(store);
            }
        }

        function nhaodiemP_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            alert("Nhập thành công");
            //KB_TIM_P_KQ(b_kq);
        }

    </script>
</asp:Content>

